package com.wushijia.highconcurrency.threadpool;

import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

/**
 * 延时任务
 */
public class ScheduledExecutorServiceDemo1 {

  private static final ScheduledExecutorService scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(
      r -> null);

  public static void main(String[] args) {
    String name = "hello";
    submitConsumeRequestLater(name);
  }

  static void submitConsumeRequestLater(String name) {

    scheduledExecutorService.schedule(new Runnable() {

      @Override
      public void run() {
        System.out.println(name);
      }
    }, 1000, TimeUnit.MILLISECONDS);
  }
}
